<?php
/**
 * Created by PhpStorm.
 * User: hlcc
 * Date: 2017/1/18
 * Time: 15:21
 */

$length = $_POST['ss_cd'];
$ss_fh_value =  $_POST['ss_fh_value'];
$ss_fh_value_arr = explode(" ",$ss_fh_value);
$ss_dx =  $_POST['ss_dx'];
$ss_xx =  $_POST['ss_xx'];
$ss_sz =  $_POST['ss_sz'];
$ss_fh =  $_POST['ss_fh'];
$arr = array_merge(
    ($ss_dx != "false")?range('A','Z'):array(),
    ($ss_xx!= "false")?range('a','z'):array(),
    ($ss_sz!= "false")?range(0,9):array(),
    ($ss_fh!= "false")?$ss_fh_value_arr:array()
);
shuffle($arr);
$str = pwd($length,$arr);
echo json_encode($str);
//密碼生成的類
function pwd($length="",$arr=array())
{
    $str_return = "";
    for ($i = 1;$i<=$length;$i++){
        $arr_key = array_rand($arr,1);
        $str_return.=$arr[$arr_key];
    }
    return $str_return;
}